home *** CD-ROM | disk | FTP | other *** search
/ Scene 96 / Scene 96 International Edition (Zyklop Software) (Disc 2) (1997).iso / misc / coding / xmasspak / _lbm / rlbm.asm next >
Encoding:
Assembly Source File  |  1995-02-13  |  5.1 KB  |  206 lines

  1. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  2. ;                                 LBM-READ
  3. ;                                ─────────
  4. ; This is a demonstration how to depack a 256 color LBM-file.
  5. ; The main-routine is called 'depack_LBM' !
  6. ; You can use this piece of code freely.......
  7. ; This routine is made to depack pictures with a resolution of 320*200 pixel.
  8. ;
  9. ;                                                      Capella/Escape
  10. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  11.  
  12. ideal
  13. model large
  14. p386n
  15. stack 256
  16.  
  17. assume cs:coding
  18.  
  19. segment  coding
  20.  
  21. start:        mov ax,pcxdata
  22.               mov ds,ax
  23.               assume ds:pcxdata
  24.                
  25.               mov ax,0a000h
  26.               mov es,ax
  27.               assume es:0a000h
  28.  
  29.               mov ax,0013h
  30.               int 10h
  31.  
  32. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  33. ;                        LOADROUTINE FOR THE PICTURE
  34. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  35.  
  36.               mov ax,3d02h
  37.               mov dx,offset file
  38.               int 21h
  39.               jc error
  40.               mov bx,ax
  41.  
  42.               mov ah,3fh
  43.               mov dx,offset puffer
  44.               mov cx,0ffffh
  45.               int 21h
  46.               jc error
  47.               mov [ds:file_length],ax
  48.  
  49.               mov ah,3eh
  50.               int 21h
  51.               jc error
  52.  
  53.               call depack_lbm
  54.  
  55.               call set_colors
  56.               
  57. warte:        in al,60h
  58.               cmp al,01h
  59.               jne warte
  60.  
  61.               mov ax,0003h
  62.               int 10h
  63.               mov ax,4c00h
  64.               int 21h
  65.  
  66. error:        mov ax,0003h
  67.               int 10h
  68.               mov dx,offset etxt
  69.               mov ah,09h
  70.               int 21h
  71.               jmp warte
  72.  
  73. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  74. ;                          THE LBM-DEPACK-ROUTINE
  75. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  76.  
  77. depack_lbm:   mov si,offset puffer
  78.               push si
  79.  
  80.               mov cx,[ds:file_length]
  81.               mov ebx,"PAMC"          ; searching for CMAP-signature
  82. search_col:   mov eax,[ds:si]
  83.               cmp eax,ebx
  84.               je colors_found
  85.               inc si
  86.               dec cx
  87.               jnz search_col
  88.  
  89.               pop si
  90.  
  91.               mov ax,0003h
  92.               int 10h
  93.               
  94.               mov ah,09h
  95.               mov dx,offset no_col
  96.               int 21h
  97.               jmp warte
  98.  
  99. colors_found: add si,8
  100.               mov [ds:color_table],si
  101.  
  102.               pop si
  103.  
  104.               mov cx,[ds:file_length]
  105.               mov ebx,"YDOB"           ; searching for BODY-signature
  106. search_gfx:   mov eax,[ds:si]
  107.               cmp eax,ebx
  108.               je bitmap_found
  109.               inc si
  110.               dec cx
  111.               jnz search_gfx
  112.  
  113.               mov ax,0003h
  114.               int 10h
  115.               mov ah,09h
  116.               mov dx,offset no_gfx
  117.               int 21h
  118.               jmp warte
  119.  
  120. bitmap_found: add si,8
  121.               mov [ds:bitmap_table],si
  122.               xor di,di
  123.  
  124. check_byte:   mov al,[ds:si]
  125.               mov ah,al
  126.               cmp di,64000
  127.               jae bitmap_end
  128.               and al,10000000b
  129.               cmp al,80h
  130.               je byte_row
  131.               
  132. single_bytes: mov cl,ah
  133.               xor ch,ch
  134.               inc cx
  135.               inc si
  136.  
  137. copy_bytes1:  mov al,[ds:si]
  138.               mov [es:di],al
  139.               inc si
  140.               inc di
  141.               dec cx
  142.               jnz copy_bytes1
  143.  
  144.               jmp check_byte
  145.  
  146. byte_row:     mov cl,ah
  147.               xor ch,ch
  148.               dec cx
  149.               inc si
  150.               
  151. copy_bytes2:  mov al,[ds:si]
  152.               mov [es:di],al
  153.               inc di
  154.               inc cx
  155.               cmp cx,0100h
  156.               jne copy_bytes2
  157.               inc si
  158.               jmp check_byte
  159.  
  160. bitmap_end:   ret
  161. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  162. ;                      SET THE COLORTABLE OF THE PCX FILE
  163. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  164.  
  165. set_colors:   mov si,[ds:color_table]
  166.               mov dx,03c8h
  167.               xor al,al
  168.               out dx,al
  169.               inc dx
  170.               mov cx,256
  171. copy_colors:  mov al,[ds:si]
  172.               shr al,2
  173.               out dx,al
  174.               mov al,[ds:si+1]
  175.               shr al,2
  176.               out dx,al
  177.               mov al,[ds:si+2]
  178.               shr al,2
  179.               out dx,al
  180.               add si,3
  181.               dec cx
  182.               jnz copy_colors
  183.               ret
  184.  
  185.  
  186. ends  coding
  187.  
  188. segment  pcxdata
  189.  
  190. file           db "testgfx.lbm",0
  191. etxt           db "error appears.....$"
  192. no_col         db "No colortable found....$"
  193. no_gfx         db "No bitmap found....$"
  194.  
  195. file_length    dw ?
  196. bitmap_table   dw ?
  197. color_table    dw ?
  198.  
  199. puffer         db 64000 dup (?)
  200.  
  201. ends  pcxdata
  202.  
  203. end start
  204.  
  205.  
  206.